<template>
	<view class="indexs">
		<view class="header header_lan" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img22.png'" mode="widthFix"></image></view>
					<view class="index_wenben baise">我的订单</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;'">
			<view class="my_dingdan_center">
				<view class="index_cardingdan">
					<view class="index_swiper">
						<!--内容布局-->
						<view class="index_list">
							<view :class="'index_list_heji' + index">
								<view class="index_cardingdan_center">
									<view class="my_dingdan_list" v-if="arrlist.length != 0">
										<view class="my_dingdan_cont" v-for="(item, index1) in arrlist" :key="index1">
											<view class="my_dingdan_title">
												<view class="my_dingdan_l">
													<image :src="imgUrl + '/dzx_img24.png'"></image>
													<text>{{ item.storage.shop_name }}</text>
												</view>
												<view class="my_dingdan_r" v-if="item.status == 1" style="color: #f33653">待查验</view>
												<view class="my_dingdan_r" v-if="item.status == 2" style="color: #f33653">待支付</view>
												<view class="my_dingdan_r" v-if="item.status == 3">已支付</view>
												<view class="my_dingdan_r" v-if="item.status == 4">拣货中</view>
												<view class="my_dingdan_r" v-if="item.status == 5">打包中</view>
												<view class="my_dingdan_r" v-if="item.status == 6">已发货</view>
												<view class="my_dingdan_r" v-if="item.status == 7">已收货</view>
												<view class="my_dingdan_r" v-if="item.status == 8">已完成</view>
												<view class="my_dingdan_r" v-if="item.status == -1">问题件</view>
											</view>
											<view class="my_dingdan_title">
												<view class="my_dingdan_l">
													<image :src="imgUrl + '/dzx_img27.png'"></image>
													<text>包裹单号：{{ item.order_sn }}</text>
												</view>
											</view>
											<view class="my_dingdan_txtlist">
												<view class="my_dingdan_txtcont" v-if="item.status == 6">
													国际单号：
													<text>{{ item.t_order_sn ? item.t_order_sn : '暂未生成' }}</text>
												</view>
												<view class="my_dingdan_txtcont">
													寄送国家：
													<text>{{ item.country?item.country.title:'' }}</text>
												</view>
												<view class="my_dingdan_txtcont">
													包裹件数：
													<text>{{ item.num }}</text>
												</view>
												<view class="my_dingdan_txtcont">
													计算重量：
													<text v-if="item.cale_weight">
														长{{ item.length }}{{ setting.size_mode.unit }} 宽{{ item.width }}{{ setting.size_mode.unit }} 高{{ item.height
														}}{{ setting.size_mode.unit }} 重量{{ item.cale_weight }}KG
													</text>
												</view>
												<view class="my_dingdan_txtcont">
													付款方式：
													<text>余额付款</text>
												</view>
												<view class="my_dingdan_txtcont">
													报备时间：
													<text>{{ item.created_time }}</text>
												</view>
												<view v-if="item.status == 2" class="my_dingdan_txtcont">
													支付金额：
													<text style="color: #f33653">{{ price_mode.unit }}{{ item.total_free }}</text>
												</view>
											</view>

											<view class="my_dingdan_btns">
												<view class="my_dingdan_btns1" @tap="chakanxq" :data-id="item.id">查看详情</view>
												<view class="my_dingdan_btns1" @tap="jointoOrder" :data-id="item.id">申请加入拼团</view>
											</view>
										</view>
									</view>
									<view class="my_dingdan_zanwu" v-else>
										<image :src="imgUrl + '/dzx_img43.png'"></image>
										<text>暂无订单</text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();

let request = require('../../../utils/require');

export default {
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			height: 0,
			heights: 0,
			currentIndex: 0,
			left: 16,
			false: false,
			width: 0,
			price_mode: uni.getStorageSync('price_mode'),
			setting: uni.getStorageSync('setting'),
			//分页
			page: 1,

			ispage: true,
			arrlist: [],
			isSwiper: false,
			optionsid: ''
		};
	},
	/**
	 * 生命周期函数--监听页面加载
	 */ onLoad(options) {
		var that = this;
		that.optionsid= options.share_id
		that.page= 1
		that.ispage= true
		that.arrlist= []
	},
	onShow() {
		var that = this;
		that.currentIndex= that.optionsid
		that.page= 1
		that.ispage= true
		that.arrlist= []
		that.isSwiper= true
		that.baoguolist();
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {
		if (this.ispage) {
			this.page= this.page + 1
			console.log(4444444444444444444);
			this.baoguolist();
		}
	},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {},
	methods: {
		jointoOrder(e) {
			var that = this;
			uni.showModal({
				title: '提示',
				content: '确认申请该订单加入拼团？',

				success(res) {
					if (res.confirm) {
						var data = {
							token: uni.getStorageSync('token'),
							id: e.currentTarget.dataset.id, //集运单id
							pin_id: that.optionsid //拼团id
						};
						request.post(`index.php?s=/api/sharp.order/applytopintuan&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
							if (res.data.code == 1) {
								uni.showToast({
									title: res.data.data
								});
								setTimeout(() => {
									that.jumpzuo();
								}, 1000);
							} else {
								uni.showToast({
									title: res.data.msg,
									icon: 'none'
								});
							}
						});
					} else {
						if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				}
			});
		},
		baoguolist() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token'),
				page: that.page
			};
			request.get(`index.php?s=/api/package/pintuanpackageList&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					if (that.page > res.data.data.last_page) {
						that.ispage= false
					} else {
						that.arrlist= that.arrlist.concat(res.data.data.data)
					}
				}
			});
		},
		chakanxq(e) {
			uni.navigateTo({
				url: '/pages/indexs/my_dingdan_details/my_dingdan_details?id=' + e.currentTarget.dataset.id
			});
		},
		jumpzuo() {
			uni.navigateBack();
		}
	}
};
</script>
<style>
@import './my_dingdan.css';
</style>
